<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/10
 * Time: 17:31
 */

namespace app\common\controller;

use think\Db;

class OnlineMonitoring{

    public function index(){
        $user = Db::name('username')->field('id,current_from,current_time,diff_time')->select();
        foreach($user as $v){
            if( intval($v['current_from']) > 0  && time()-intval($v['diff_time']) > 300 ){
                Db::name('username')->where(['id'=>$v['id']])->update(['current_from'=>0]);
            }
        }
    }
}